package com.example.mapper;

import com.example.pojo.Users;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Mybatis纯注解开发
 */
public interface TUsersMapper {

    @Select("select * from users")
    List<Users> selectAll();

    @Select("select * from users where uid = #{id}")
    Users selectById(Integer id);

    /* 如果有多个形参，需要为每个形参指定一个param的值 */
    @Select("select * from users where uid = #{uid} or uage = #{uage}")
    List<Users> selectByParams(@Param("uid") Integer a,
                               @Param("uage") Integer b);

    @Insert("insert into users (uname, uage) VALUES (#{uname}, #{uage})")
    int insert(Users users);

    @Update("update users set uname = #{uname}, uage = #{uage} where uid = #{uid}")
    int update(Users users);

    @Delete("delete from users where uid = #{uid}")
    int deleteById(Integer uid);
}
